package com.sw.haruka.helper.extens

import androidx.lifecycle.LifecycleOwner
//import com.uber.autodispose.AutoDispose
//import com.uber.autodispose.ObservableSubscribeProxy
//import com.uber.autodispose.SingleSubscribeProxy
//import com.uber.autodispose.android.lifecycle.AndroidLifecycleScopeProvider
//import io.reactivex.Observable
//import io.reactivex.Single
//import io.reactivex.android.schedulers.AndroidSchedulers
//import io.reactivex.schedulers.Schedulers
//
////////////////////////////////RxJava////////////////////////////
//fun <T> Single<T>.async(withDelay: Long = 0): Single<T> =
//    this.subscribeOn(Schedulers.io()).delay(withDelay, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread())
//
///* 用来绑定Activity的生命周期，避免内存泄漏 */
//fun <T> Single<T>.bindLifeCycle(owner: LifecycleOwner): SingleSubscribeProxy<T> {
//    return this.`as`(AutoDispose.autoDisposable(AndroidLifecycleScopeProvider.from(owner, Lifecycle.Event.ON_DESTROY)))
//}
//
//fun <T> Observable<T>.bindLifeCycle(owner: LifecycleOwner): ObservableSubscribeProxy<T> {
//    return this.`as`(AutoDispose.autoDisposable(AndroidLifecycleScopeProvider.from(owner, Lifecycle.Event.ON_DESTROY)))
//}
//
//
///* 延时执行方法，默认延时 1 秒 */
//fun setInterval(function: ()->Unit, delayMillisTime: Long = 1000) = Single.just(true)
//        .async(delayMillisTime)
//        .subscribe({
//            function()
//        }, {
//
//        })
